/*课程总数*/
create or replace function count_course()
returns integer as $$

declare
counts integer;

begin select count(*) into counts from courses;
return counts;
end;

$$ language plpgsql;

/*调用课程总数*/
select count_course();


/*学生总数*/
create or replace function count_student()
returns integer as $$

declare
counts integer;

begin select count(*) into counts from students;
return counts;
end;

$$ language plpgsql;

/*调用学生总数*/
select count_student();


/*账目总数*/
create or replace function count_account()
returns integer as $$

declare
counts integer;

begin select count(*) into counts from accounts;
return counts;
end;

$$ language plpgsql;

/*调用账目总数*/
select count_account();


/*教师总数*/
create or replace function count_teacher()
returns integer as $$

declare
counts integer;

begin select count(*) into counts from teachers;
return counts;
end;

$$ language plpgsql;

/*调用教师总数*/
select count_teacher();